package com.mudalov.rec.dao.model.user;

import com.mudalov.rec.dao.interfaces.IClonable;
import java.util.Set;

import com.mudalov.rec.dao.model.study.StudyProgram;
import com.mudalov.rec.dao.model.study.TestResult;
import java.util.HashSet;

public class Student extends User implements IClonable<Student> {

	private static final long serialVersionUID = 4373490569615328884L;

	private String group;

	private Set<StudyProgram> programs;

	private Set<TestResult> testResults;

	public Student() {
        testResults = new HashSet<TestResult>();
        programs = new HashSet<StudyProgram>();
	}

	public Student(String fullName, String login, String eMail, Set<Message> messages,
			String password, Role role, String group,
			Set<StudyProgram> programs, Set<TestResult> testResults) {
		super();
        this.eMail = eMail;
		this.fullName = fullName;
		this.login = login;
		this.messages = messages;
		this.password = password;
		this.role = role;
		this.group = group;
		this.programs = programs;
		this.testResults = testResults;
	}

    public Student(String fullName, String login, String eMail, String password, Role role) {
        this(fullName, login, eMail, null,
                password, role, null,
                null, null);
    }

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public Set<StudyProgram> getPrograms() {
		return programs;
	}

	public void setPrograms(Set<StudyProgram> programs) {
		this.programs = programs;
	}

	public Set<TestResult> getTestResults() {
		return testResults;
	}

	public void setTestResults(Set<TestResult> testResults) {
		this.testResults = testResults;
	}

    @Override
    public boolean isAdmin() {
        return false;
    }

    @Override
    public boolean isTeacher() {
        return false;
    }

    @Override
    public boolean isStudent() {
        return true;
    }

    public Student getClone() {
        Student clone = new Student();
        clone.setFullName(this.getFullName());
        clone.setGroup(this.getGroup());
        clone.setId(this.getId());
        clone.setLogin(this.getLogin());
        clone.setMail(this.getMail());
        if (this.getMessages() != null) {
            for (Message message : this.getMessages()) {
                clone.getMessages().add(message.getClone());
            }
        }
        clone.setPassword(this.getPassword());
        for (StudyProgram program : this.getPrograms()) {
            clone.getPrograms().add(program.getClone());
        }
        if (this.getRole() != null) {
           clone.setRole(this.getRole().getClone());
        }
        if (this.getTestResults() != null) {
            for (TestResult testResult : this.getTestResults()) {
                clone.getTestResults().add(testResult.getClone());
            }
        }

        return clone;
    }
}
